home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / access2a / frmmain.frm < prev    next >
Text File  |  1999-10-17  |  9KB  |  272 lines

  1. VERSION 5.00
  2. Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
  3. Begin VB.Form frmMain 
  4.    Caption         =   "Access Password Finder"
  5.    ClientHeight    =   1950
  6.    ClientLeft      =   60
  7.    ClientTop       =   345
  8.    ClientWidth     =   5625
  9.    BeginProperty Font 
  10.       Name            =   "MS Sans Serif"
  11.       Size            =   8.25
  12.       Charset         =   0
  13.       Weight          =   700
  14.       Underline       =   0   'False
  15.       Italic          =   0   'False
  16.       Strikethrough   =   0   'False
  17.    EndProperty
  18.    Icon            =   "frmMain.frx":0000
  19.    LinkTopic       =   "Form1"
  20.    MaxButton       =   0   'False
  21.    Picture         =   "frmMain.frx":0442
  22.    ScaleHeight     =   1950
  23.    ScaleWidth      =   5625
  24.    StartUpPosition =   3  'Windows Default
  25.    Begin VB.CheckBox chkUse3 
  26.       Caption         =   "Try other Key"
  27.       BeginProperty Font 
  28.          Name            =   "Small Fonts"
  29.          Size            =   6.75
  30.          Charset         =   0
  31.          Weight          =   400
  32.          Underline       =   0   'False
  33.          Italic          =   0   'False
  34.          Strikethrough   =   0   'False
  35.       EndProperty
  36.       Height          =   210
  37.       Left            =   3840
  38.       TabIndex        =   8
  39.       Top             =   990
  40.       Width           =   1170
  41.    End
  42.    Begin VB.CommandButton btnPass2000 
  43.       Caption         =   "Find 2000 Password"
  44.       Height          =   375
  45.       Left            =   2925
  46.       TabIndex        =   6
  47.       Top             =   615
  48.       Width           =   2055
  49.    End
  50.    Begin VB.CommandButton btnPass97 
  51.       Caption         =   "Find 97 Password"
  52.       Height          =   375
  53.       Left            =   1125
  54.       TabIndex        =   5
  55.       Top             =   615
  56.       Width           =   1815
  57.    End
  58.    Begin VB.TextBox txtPass 
  59.       BeginProperty Font 
  60.          Name            =   "MS Sans Serif"
  61.          Size            =   8.25
  62.          Charset         =   0
  63.          Weight          =   400
  64.          Underline       =   0   'False
  65.          Italic          =   0   'False
  66.          Strikethrough   =   0   'False
  67.       EndProperty
  68.       Height          =   375
  69.       Left            =   1125
  70.       TabIndex        =   2
  71.       Top             =   1335
  72.       Width           =   2175
  73.    End
  74.    Begin VB.CommandButton btnOpen 
  75.       Caption         =   "..."
  76.       Height          =   375
  77.       Left            =   4845
  78.       TabIndex        =   1
  79.       Top             =   255
  80.       Width           =   375
  81.    End
  82.    Begin MSComDlg.CommonDialog CommonDialog1 
  83.       Left            =   120
  84.       Top             =   1275
  85.       _ExtentX        =   847
  86.       _ExtentY        =   847
  87.       _Version        =   393216
  88.    End
  89.    Begin VB.TextBox txtFileName 
  90.       BeginProperty Font 
  91.          Name            =   "MS Sans Serif"
  92.          Size            =   8.25
  93.          Charset         =   0
  94.          Weight          =   400
  95.          Underline       =   0   'False
  96.          Italic          =   0   'False
  97.          Strikethrough   =   0   'False
  98.       EndProperty
  99.       Height          =   375
  100.       Left            =   1125
  101.       TabIndex        =   0
  102.       Top             =   255
  103.       Width           =   3735
  104.    End
  105.    Begin VB.Label lblAbout 
  106.       AutoSize        =   -1  'True
  107.       Caption         =   "Written by Dan Fogelberg 1999"
  108.       BeginProperty Font 
  109.          Name            =   "Small Fonts"
  110.          Size            =   6.75
  111.          Charset         =   0
  112.          Weight          =   400
  113.          Underline       =   0   'False
  114.          Italic          =   0   'False
  115.          Strikethrough   =   0   'False
  116.       EndProperty
  117.       Height          =   165
  118.       Left            =   3585
  119.       TabIndex        =   7
  120.       Top             =   1725
  121.       Width           =   1845
  122.    End
  123.    Begin VB.Label lblPassword 
  124.       Caption         =   "Password"
  125.       BeginProperty Font 
  126.          Name            =   "MS Sans Serif"
  127.          Size            =   8.25
  128.          Charset         =   0
  129.          Weight          =   400
  130.          Underline       =   0   'False
  131.          Italic          =   0   'False
  132.          Strikethrough   =   0   'False
  133.       EndProperty
  134.       Height          =   255
  135.       Left            =   1140
  136.       TabIndex        =   4
  137.       Top             =   1095
  138.       Width           =   855
  139.    End
  140.    Begin VB.Label lblFileName 
  141.       Caption         =   "File Name"
  142.       BeginProperty Font 
  143.          Name            =   "MS Sans Serif"
  144.          Size            =   8.25
  145.          Charset         =   0
  146.          Weight          =   400
  147.          Underline       =   0   'False
  148.          Italic          =   0   'False
  149.          Strikethrough   =   0   'False
  150.       EndProperty
  151.       Height          =   255
  152.       Left            =   1125
  153.       TabIndex        =   3
  154.       Top             =   15
  155.       Width           =   735
  156.    End
  157. End
  158. Attribute VB_Name = "frmMain"
  159. Attribute VB_GlobalNameSpace = False
  160. Attribute VB_Creatable = False
  161. Attribute VB_PredeclaredId = True
  162. Attribute VB_Exposed = False
  163. '-------------------------------------------------------
  164. 'This is a handy little routine for retrieving
  165. 'forgotten passwords out of Access97 and 2000.
  166. '
  167. 'The original code for Access97 was found on a
  168. 'newsgroup and I translated it to VB.  It would
  169. 'not work on 2000 so I fixed that!  The 97 code
  170. 'should also work on Access 2+, but I have not
  171. 'checked that.
  172. '
  173. 'Do not abuse this.  This should be used only for
  174. 'databases you originally had permissions to and
  175. 'forgot the password.
  176. '
  177. '-Dan Fogelberg
  178. 'DanFogelberg@newmail.net
  179. '
  180. 'Disclaimer:
  181. 'Use this code at your own risk!  I take no responsibility
  182. 'for it.
  183. '-------------------------------------------------------
  184. 'Use:
  185. '   Select the appropriate MDB file and then
  186. '   Click the button for the version.  If you
  187. '   Do not know the version try both... :-)
  188. '   If you get gibberish well then it must be
  189. '   the other!  Enjoy and send comments to above.
  190.  
  191. Private Sub btnPass2000_Click()
  192.     On Error GoTo errHandler
  193.     Dim ch(40) As Byte
  194.     Dim x As Integer, sec2, intChar As Integer, blnUse3 As Boolean
  195.     If Trim(txtFileName) = "" Then Exit Sub
  196.     'Used integers instead of hex :-)  Easier to read
  197.     sec2 = Array(0, 194, 117, 236, 55, 25, 202, 156, 250, 130, 208, 40, 230, 87, 56, 138, 96, 16, 26, 123, 54, 177, 252, 223, 177, 51, 122, 19, 67, 139, 33, 177, 51, 112, 239, 121, 91, 214, 59, 124, 42)
  198.     'I found that some DB's use this scheme see below for the logic to determine which is which :-)
  199.     sec3 = Array(0, 229, 117, 236, 55, 62, 202, 156, 250, 165, 208, 40, 230, 112, 56, 138, 96, 55, 26, 123, 54, 150, 252, 223, 177, 20, 122, 19, 67, 172, 33, 177, 51, 87, 239, 121, 91, 241, 59, 124, 42)
  200.     txtPass.Text = ""
  201.     blnUse3 = False
  202.     
  203.     Open txtFileName.Text For Binary Access Read As #1 Len = 40
  204.     Get #1, &H42, ch
  205.     Close #1
  206.     'Check to see which key by running through first 6 letters of password
  207.     'This is not foolproof by any means.
  208.     For x = 1 To 6
  209.       intChar = ch(x) Xor sec2(x)
  210.          'This is kind of lame but it assumes that most passwords
  211.          'are in this range of keyboard chars :-)
  212.       If ((intChar < 32) Or (intChar > 126)) And (intChar <> 0) Then
  213.          blnUse3 = True 'Set a flag
  214.       End If
  215.     Next x
  216.     'Allow force of key3.
  217.     If chkUse3.Value = vbChecked Then
  218.       blnUse3 = True
  219.     End If
  220.     'Now solve for password
  221.     For x = 1 To 40
  222.          If blnUse3 = True Then
  223.             intChar = ch(x) Xor sec3(x)
  224.          Else
  225.             intChar = ch(x) Xor sec2(x)
  226.          End If
  227.          txtPass.Text = txtPass.Text & Chr(intChar)
  228.     Next x
  229.     Exit Sub
  230. errHandler:
  231.     MsgBox "ERROR occcured:" & vbCrLf & Err.Number & ":  " & Err.Description, vbCritical, "ERROR"
  232.     Exit Sub
  233. End Sub
  234.  
  235. Private Sub btnPass97_Click()
  236. On Error GoTo errHandler
  237.     Dim ch(18) As Byte, x As Integer
  238.     Dim sec
  239.     If Trim(txtFileName) = "" Then Exit Sub
  240.     'Used integers instead of hex :-)  Easier to re